<?php $this -> load -> view('adminx/header'); ?>
<!-- BEGIN CONTAINER -->
<div class="page-container">
	<!-- BEGIN SIDEBAR -->
	<?php $this -> load -> view('adminx/mune'); ?>
	<!-- END SIDEBAR -->
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
			<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
			<!-- /.modal -->
			<h3 class="page-title"> <?php echo $title; ?> <small><?php echo $en; ?></small></h3>
			<div class="page-bar">
				<ul class="page-breadcrumb">
					<li>
						<i class="fa fa-home"></i>
						<a href="/adminx">首页</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="/iadmin/sp"><?php echo $title; ?></a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#">修改商品</a>
					</li>
				</ul>
			</div>
			<!-- END PAGE HEADER-->
			<div class="clearfix"></div>
			<div class="row">
		<div class="col-lg-12 col-md-12">
			<div class="note note-success">
						<p>1，选择了供货机构，选择启动通过红包发送供货款，同时填写了供货价格，满足这3个设置，在会员确定收货时，供货款项会通过红包发送出去；</p>
						<p>2，代理积分即红包的金额，设置为0，就禁止了这个级别的大掌柜收到红包；</p>
						<p>3，库存为0，或销售价格为0，或者商品下架时，这个商品加入不了购物车；</p>
						<p>4，供货发送为：到店消费，购物车会显示该供货机构的地址、联系方式等信息；</p>
						<p>5，当礼券金额不为0，会员实际需要支付的金额为：供货价格减去礼券金额，购物车会显示礼券金额的信息；</p>
					</div>
			<div class="portlet light ">
				<div class="portlet-title">
							<div class="caption">
								<i class="icon-share font-red-sunglo"></i>
								<span class="caption-subject font-red-sunglo bold uppercase"> 修改商品</span>
							</div>
							<div class="actions">
								<a class="btn btn-circle btn-icon-only blue" href="javascript:;" onclick="alert_ts('<?php echo $this -> config -> item('xt_ts'); ?>')"> <i class=" icon-bulb"></i> </a>
								<a class="btn btn-circle btn-icon-only btn-default fullscreen" href="javascript:;"> </a>
							</div>
						</div>
				<div class="portlet-body">
					<form role="form" method="post" id="add_sp">
							<div class="form-group">
								<?php echo $this -> form -> doform('classd', 'fl1', '', $mx['fl1'],'3'); ?>
							</div>
							<div class="form-group">
								<label>名称</label>
								<input class="form-control" name="name" placeholder="名称" value="<?php echo $mx['name']; ?>"/>
							</div>
							<div class="form-group">
								<label>品牌</label>
								<select class="form-control" name="brand_id">
									<?php foreach($brand as $v){ ?>
									<option  <?php if($mx['brand_id']==$v['id']){ echo 'selected'; }?>  value="<?php echo $v['id']; ?>"><?php echo $v['name']; ?></option>
									<?php } ?>
								</select>
							</div>
							<div class="form-group">
								<label>标签</label>
								<input class="form-control" name="bq" placeholder="多个标签用&分开，比如：&蔬菜&海鲜&牛肉&" value="<?php echo $mx['bq']; ?>"/>
							</div>
							<div class="form-group">
								<label>编号</label>
								<input class="form-control" name="bh" placeholder="编号" value="<?php echo $mx['bh']; ?>"/>
							</div>
							<div class="form-group">
								<label>库存项</label>
								<input type="hidden" class="form-control" id="color_item" name="color_item" placeholder="颜色或款式" value="<?php echo $mx['color_item']; ?>"/>
								<input type="hidden" class="form-control" id="colorx" name="color" placeholder="颜色或款式" value="<?php echo $mx['color']; ?>"/>
								<p>
								<div class="input-group" style="width: 300px;">
								<select id="color_type" class="form-control">
									<?php foreach($this->config->item('color_type') as $k=>$v){?>
									<option value="<?php echo $k; ?>"><?php echo $v; ?></option>
									<?php } ?>
								</select>
								<span class="input-group-btn">
								      <button style="display: inline-block;" onclick="add_color_type()" type="button" class="btn btn-default">添加</button>
								</span>
								</div>
								</p>
								<hr />
								<div id="color_type_body">
									
								</div>
								
								<br />
								<table class="table table-bordered" id="color_table" style="display: none;">
									<tbody id="color_tbody">
									<tr id="color_tbody_head">
										<td width="100">价格</td>
										<td width="100">库存</td>
										<td width="100">编号</td>
									</tr>
									</tbody>
                                 </table>
							</div>
							<div class="form-group" style="display: none;">
								<div class="row">
  <div class="col-lg-6">
    <div class="input-group">
    	<input type="text" class="form-control" placeholder="请输入数字" id="ty_jg">
      <span class="input-group-btn">
        <button onclick="ty_jgx()" class="btn btn-default" type="button">统一设置价格</button>
      </span>
      
    </div><!-- /input-group -->
  </div><!-- /.col-lg-6 -->
  <div class="col-lg-6">
    <div class="input-group">
      <input type="text" class="form-control" placeholder="请输入数字" id="ty_kc">
      <span class="input-group-btn">
        <button onclick="ty_kcx()" class="btn btn-default" type="button">统一设置库存</button>
      </span>
    </div><!-- /input-group -->
  </div><!-- /.col-lg-6 -->
</div><!-- /.row -->
							</div>
							<div class="form-group">
								<label>库存量</label>
								<input class="form-control" name="kc" id="set_kc" placeholder="填写数字" value="<?php echo $mx['kc']; ?>"/>
							</div>
							<div class="form-group">
								<label>推荐语</label>
								<input class="form-control" name="tj" placeholder="推荐语" value="<?php echo $mx['tj']; ?>"/>
							</div>
							<div class="form-group">
								<label>排序</label>
								<input class="form-control" name="sort" placeholder="越小越靠前" value="<?php echo $mx['sort']; ?>"/>
							</div>
							<div class="form-group">
								<?php echo $this -> form -> doform('pic', 'pic1', '', $mx['pic1']); ?>
							</div>
							<div class="form-group">
								<?php echo $this -> form -> doform('pic', 'pic2', '', $mx['pic2']); ?>
							</div>
							<div class="form-group">
								<?php echo $this -> form -> doform('pic', 'pic3', '', $mx['pic3']); ?>
							</div>
							<div class="form-group">
								<label>购买按钮</label>
								<?php echo $this -> form -> doform('pic', 'gm_bt', '', $mx['gm_bt']); ?>
							</div>
							
							<div class="form-group">
								<label>推荐图片</label>
								<?php echo $this -> form -> doform('pic', 'tj_pic', '', $mx['tj_pic']); ?>
							</div>
							
							<div class="form-group">
								<label>市场价格</label>
								<input class="form-control" name="price_sc" placeholder="只填写数字" value="<?php echo $mx['price_sc']; ?>"/>
							</div>
							<div class="form-group">
								<label>销售价格</label>
								<input class="form-control" name="price" placeholder="只填写数字" value="<?php echo $mx['price']; ?>"/>
							</div>
							<div class="form-group">
								<label>供货价格</label>
								<input class="form-control" name="sk_je" placeholder="供货商价格" value="<?php echo $mx['sk_je']; ?>"/>
							</div>
							
							<div class="form-group">
								<label>提货方式</label>
								 <select  id="xffs" name="xffs" class="form-control">
								 	<option value="1" <?php if($mx['xffs']==1){ echo 'selected'; }?>  >物流快递</option>
								 	<option value="2" <?php if($mx['xffs']==2){ echo 'selected'; }?> >到店消费</option>
								 	<option value="3" <?php if($mx['xffs']==3){ echo 'selected'; }?>  >无物流商品（支付完成，立即发送红包）</option>
								 	<?php if($this->config->item('plug_voice')){ ?>
								 	<option value="4" <?php if($mx['xffs']==4){ echo 'selected'; }?> >课程</option>
								 	<?php } ?>
								 </select>
							</div>
							<?php $yx=array(1,2); if(in_array($this->session->userdata('state'), $yx)){ ?>
							<div class="form-group">
								<label>供货机构</label>
								 <select  id="staff_id" name="staff_id" class="form-control">
								 	<option value="0">请选择供货机构</option>
    	                   <?php
    	//获取提货的店铺
				$this -> db -> select('staff_id,jg_name,jg_qy');
				$this -> db -> group_by('jg_qy');
				$q = $this -> db -> get_where('staff', array('state' => 3, 'staff_del' => 1));
				$shop = $q -> result_array();
    	 foreach($shop as $v){?>
    	<optgroup label="<?php echo $v['jg_qy']; ?>">
    		<?php $this -> db -> select('staff_id,jg_name,jg_qy');  $q=$this->db->get_where('staff',array('jg_qy'=>$v['jg_qy'],'state' => 3, 'staff_del' => 1)); foreach($q->result_array() as $vv){  ?>
            <option   <?php  if($mx['staff_id']==$vv['staff_id']){ echo 'selected'; }  ?> value="<?php echo $vv['staff_id']; ?>"><?php echo $vv['jg_name']; ?></option>
         <?php } ?>
     </optgroup>
    <?php } ?>
    </select>
							</div>
							
							
							<div class="form-group">
								<label>是否通过红包发送供货款</label>
								<select name="sk_is" class="form-control">
									<option <?php if($mx['sk_is']==2){ echo 'selected'; } ?> value="2">关闭</option>
									<option <?php if($mx['sk_is']==1){ echo 'selected'; } ?> value="1">启用</option>
								</select>
							</div>
							
							<div class="form-group">
								<label>一级代理积分</label>
								<input class="form-control" name="dl" placeholder="只填写数字" value="<?php echo $mx['dl']; ?>"/>
							</div>
							<div class="form-group">
								<label>二级代理积分</label>
								<input class="form-control" name="dl1" placeholder="只填写数字" value="<?php echo $mx['dl1']; ?>"/>
							</div>
							<div class="form-group">
								<label>三级代理积分</label>
								<input class="form-control" name="dl2" placeholder="只填写数字" value="<?php echo $mx['dl2']; ?>"/>
							</div>
							<div class="form-group">
								<label>礼券金额</label>
								<input class="form-control" name="lq" placeholder="只填写数字" value="<?php echo $mx['lq']; ?>"/>
							</div>
							
							<div class="form-group">
								<label>回馈红包</label>
								<input class="form-control number" name="hb1" placeholder="只填写数字"value="<?php echo $mx['hb1']; ?>"/>
							</div>
							
							<div class="form-group">
								<select class="form-control" name="sj">
									<option <?php if($mx['sj']==1){ echo 'selected'; } ?> value="1">上架</option>
									<option <?php if($mx['sj']==2){ echo 'selected'; } ?> value="2">下架</option>
								</select>
							</div>
							<div class="form-group">
								<label>首页推荐</label>
								<select class="form-control" name="sy">
									<option <?php if($mx['sy']==1){ echo 'selected'; } ?> value="1">推荐</option>
									<option <?php if($mx['sy']==2){ echo 'selected'; } ?> value="2">不推荐</option>
								</select>
							</div>
							<div class="form-group">
								<label>购买权限</label>
								<select class="form-control" name="shopowner">
									<option  <?php if($mx['shopowner']==1){ echo 'selected'; } ?>  value="1">开放购买权限</option>
									<option  <?php if($mx['shopowner']==2){ echo 'selected'; } ?>  value="2">仅微店店长可购买</option>
								</select>
							</div>
							<?php } ?>
							
							<div class="form-group">
								<label>简介</label>
								<textarea class="form-control" style="height: 100px;" name="jj" placeholder=""><?php echo $mx['jj']; ?></textarea>
							</div>
							<div class="form-group">
								<script type="text/plain" id="myEditor" style="width:100%;height:300px;">
									<?php echo $mx['ms']; ?>
                                 </script>
								<textarea id="myEditor_d" class="form-control" style="display: none;" name="ms" placeholder="内容"></textarea>
							</div>
							<button type="reset" class="btn default">
								<i class="fa fa-refresh"></i>
								重置
							</button>
							<button type="submit" class="btn blue">
								<i class="fa fa-send"></i>
								修改商品
							</button>
						</form>
				</div>
			</div>
		</div>

</div>
		</div>
	</div>
	<!-- BEGIN QUICK SIDEBAR -->
	<?php $this -> load -> view('adminx/lt'); ?>
	<!-- END QUICK SIDEBAR -->
</div>
<!-- END CONTAINER -->
<!-- BEGIN FOOTER -->

<?php $this -> load -> view('adminx/footer'); ?>
<link href="/mex/global/plugins/uk/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
<script type="text/javascript" charset="utf-8" src="/mex/global/plugins/uk/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/mex/global/plugins/uk/umeditor.min.js"></script>
<script type="text/javascript" src="/mex/global/plugins/uk/lang/zh-cn/zh-cn.js"></script>

<script src="/mex/global/plugins/ajaxfileupload.js"></script>
<script src="/mex/lance/sgl_color.js"></script>
<script>
	$(function() {
		var um = UM.getEditor('myEditor');
		
		up_form($("#add_sp"), "/iadmin/sp/up/<?php echo $mx['sp_id']; ?>", "修改商品", function(msg) {
			if (msg.type == 1) {
				alert_ts('修改商品成功，3秒后回到商品列表...');
				setTimeout(function(){
					window.location.href="/iadmin/sp";
				},3000);
			} else {
				alert_ts('修改商品失败！');
			}
		});
	}); 
</script>
